package main

import (
	"context"
)

// App struct
type App struct {
	ctx context.Context
}

// NewApp creates a new App application struct
func NewApp() *App {
	return &App{}
}

// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
	a.ctx = ctx
}

func (a *App) Factorial(n int64) int64 {
	var res int64 = 1
	for i := n; i > 1; i-- {
		res *= i
	}
	return res
}

func (a *App) ArrangementCalc(m, n int64) int64 {
	return a.Factorial(n) / a.Factorial(n-m)
}

func (a *App) CombinationCalc(m, n int64) int64 {
	return a.Factorial(n) / (a.Factorial(m) * a.Factorial(n-m))
}
